package my.action.article;

import java.sql.Date;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import my.controller.Action;
import my.controller.ActionForward;
import my.db.DAO.ArticleDAO;
import my.db.DTO.ArticleDTO;

public class ArticleSearchAction implements Action{
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{
			ActionForward forward=new ActionForward();
			String startDate=request.getParameter("fromdate");
			String endDate=request.getParameter("todate");
			ArrayList<ArticleDTO> list_au=new ArrayList<ArticleDTO>();
			ArticleDAO adao=new ArticleDAO();
			ArticleDTO dto=new ArticleDTO();
			ArrayList<ArticleDTO> lst_art=adao.search(startDate, endDate);
			forward.setRedirect(false);
			if(lst_art !=null){
					request.setAttribute("list_article", lst_art);
					forward.setPath("./report_article.jsp");
			}else{
				forward.setPath("./report_article.jsp?error=Reports not found");
			}
		   return forward;
		}  	
}
